package com.scfw.start;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * Created by sehuaqi on 2017/7/1.
 */
@RestController
@EnableConfigurationProperties({MyInfo.class,TestScfw.class})
public class MyController {

    @Autowired
    private MyInfo myInfo;

    @Value("${my.name}")
    private String myName;

    @Value("${my.age}")
    private int myAge;

    @RequestMapping(value = "/myInfo")
    public String myInfo() {
        return "My name is " + myName +", I'm "+ myAge + " years old.";
    }

    @RequestMapping(value = "/myInfoFromBean")
    public MyInfo myInfoFromBean() {

        return myInfo;
    }

    @Autowired
    private TestScfw testScfw;

    @RequestMapping(value = "/testScfw")
    public String testScfw() {

        return testScfw.getName()+", "+testScfw.getAge();
    }

}
